package cn.ppool.xmlmapper.worker;

import cn.ppool.xmlmapper.builder.MapperBuilder;
import lombok.Setter;
import org.springframework.beans.factory.FactoryBean;


public class ProxyFactory<T> implements FactoryBean<T> {

    @Setter
    private Class<T> interfaceClass;

    @Setter
    private MapperBuilder configure;


    @Override
    public T getObject() throws Exception {
        Worker worker = new Worker();
        worker.setConfigure(this.configure);
        return (T) worker.bind(this.interfaceClass);
    }

    @Override
    public Class<?> getObjectType() {
        return this.interfaceClass;
    }

    @Override
    public boolean isSingleton() {         // 单例模式
        return true;
    }


}
